<template>
  <div :class="$style.panel">
    <div class="header" v-if="title">
      <div class="title_box">
        <el-button icon="el-icon-back" @click="goBack" v-if="useBack"></el-button>
        <div class="title">{{title}}</div>
      </div>
      <slot class="ext" name="ext" />
    </div>
    <div class="body">
        <slot name="body" />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ""
    },
    useBack: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    goBack(){
      this.$router.go(-1)
    }
  }
};
</script>
<style module lang='scss'>
.panel {
  background: #ffffff;
  box-shadow: 0 5px 10px 0 rgba(170, 177, 183, 0.1);
  border-radius: 4px;
  margin-bottom: 20px;

  :global {
    .header {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      justify-content: space-between;
      align-items: center;
      padding: 0 20px;
      border-bottom: 1px solid #e0e2e9;
      height: 50px;
      .title_box{
        button{
          padding: 10px;
          margin-right: 20px;
        }
      }
      
      .title {
        font-size: 16px;
        font-weight: 600;
        display: inline-block;
      }

      .ext {
        display: flex;
        align-items: center;
        :global(.el-range-separator) {
          padding: 0;
        }
        :global(.el-range__icon) {
          font-size: 14px !important;
        }
      }
    }
    .body {
      padding: 16px 20px;
    }
  }
}
</style>
